import requests,json
from threading import Thread
from 账号密码规则 import f1
from 登录脚本 import soloLogin

userInfo = {
    "userName":2,
    "password":222
}
loginUrl = "http://localhost:9000/userlogin"
header = {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Connection": "keep-alive",
    "Content-Type": "application/json",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
                  "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
}
userObj = {
    "userName":2,
    "password":2*111
}

ses = soloLogin(userObj)
# ses = requests.session()
# req = ses.post(loginUrl,data = json.dumps(userObj),headers =header )
#
# PStoken = json.loads(req.text)["data"]["token"]
# ses.headers["PStoken"] = PStoken


registerurl = "http://localhost:9000/register"



newUserList = []
for i in range(300,333):
    obj = f1(i)
    newUserList.append(obj)

def reg(newUser):
    req = ses.post(registerurl,json.dumps(newUser),headers =header)
    print(req.text)

for i in newUserList:
    t = Thread(target=reg, args=(i,))
    t.start()
